/*
 SGRecyclableItem.m
 Date Created: April 16, 2010
 
 Author: Karol Krizka <kkrizka@gmail.com>
 
 Copyright (C) 2010 Green-Power
 
 URL: http://code.google.com/p/green-power
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 3 of the License, or
 (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
 $Id$
 
 */

#import "SGRecyclableItem.h"

#import "SGSortingGame.h"

@implementation SGRecyclableItem 

@dynamic y;
@dynamic x;
@dynamic type;
@dynamic lifeGiver;
@dynamic owner;

- (float)x {
  [self willAccessValueForKey:@"x"];
  NSNumber *xObj=[self primitiveValueForKey:@"x"];
  [self didAccessValueForKey:@"x"];
  return xObj.floatValue;
}

- (void)setX:(float)newX {
  [self willChangeValueForKey:@"x"];
  [self setPrimitiveValue:[NSNumber numberWithFloat:newX] forKey:@"x"];
  [self didChangeValueForKey:@"x"];
}

- (float)y {
  [self willAccessValueForKey:@"y"];
  NSNumber *yObj=[self primitiveValueForKey:@"y"];
  [self didAccessValueForKey:@"y"];
  return yObj.floatValue;
}

- (void)setY:(float)newY {
  [self willChangeValueForKey:@"y"];
  [self setPrimitiveValue:[NSNumber numberWithFloat:newY] forKey:@"y"];
  [self didChangeValueForKey:@"y"];
}

- (BOOL)lifeGiver {
  [self willAccessValueForKey:@"lifeGiver"];
  NSNumber *lifeGiverObj=[self primitiveValueForKey:@"lifeGiver"];
  [self didAccessValueForKey:@"lifeGiver"];
  return lifeGiverObj.boolValue;
}

- (void)setLifeGiver:(BOOL)newLifeGiver {
  [self willChangeValueForKey:@"lifeGiver"];
  [self setPrimitiveValue:[NSNumber numberWithBool:newLifeGiver] forKey:@"lifeGiver"];
  [self didChangeValueForKey:@"lifeGiver"];
}

- (SGRecyclableType *)type {
  [self willAccessValueForKey:@"type"];
  NSString *typeStr=[self primitiveValueForKey:@"type"];
  [self didAccessValueForKey:@"type"];
  return [SGRecyclableType typeForUniqueName:typeStr];
}

- (void)setType:(SGRecyclableType *)newType {
  [self willChangeValueForKey:@"type"];
  [self setPrimitiveValue:newType.uniqueName forKey:@"type"];
  [self didChangeValueForKey:@"type"];
}

@end
